package com.example.boot6rabbitmq.config;
import org.springframework.amqp.core.AcknowledgeMode;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//@Configuration
public class ConsumeConfig {

   // @Bean(name="qos_4")
    public SimpleRabbitListenerContainerFactory
        getSimpleRabbitListenerContainerFactory(ConnectionFactory connectionFactory) {
        SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
        factory.setMaxConcurrentConsumers(4);
        factory.setConnectionFactory(connectionFactory);
        factory.setAcknowledgeMode(AcknowledgeMode.MANUAL);//手动确认
        //factory.setAcknowledgeMode(AcknowledgeMode.AUTO);//自动确认
        factory.setFailedDeclarationRetryInterval(2000l);
        return factory;
    }
}
